import request from '@/utils/request'
import { ApiModulesRoutes } from '@/consts.js'

/**
 * 查询菜单
 */

export function getMenuList(params) {
  return request({
    url: `${ApiModulesRoutes.USER}/menu/findMenuList`,
    method: 'GET',
    params,
  })
}

/**
 * 添加菜单
 * @param {String} data.name
 * @param {String} data.subName
 * @param {String} data.path
 * @param {String} data.pid
 * @param {String} data.menuTypeEnum
 */

export function addMenuList(data) {
  return request({
    url: `${ApiModulesRoutes.USER}/menu/addMenu`,
    method: 'POST',
    data,
  })
}

/**
 * 删除菜单
 * @param {string} menuId
 */

export function delMenuList(menuId) {
  return request({
    url: `${ApiModulesRoutes.USER}/menu/delMenuById`,
    method: 'GET',
    params: { menuId },
  })
}

/**
 * 修改菜单
 * @param {String} data.name
 * @param {String} data.subName
 * @param {String} data.path
 * @param {String} data.pid
 */

export function updateMenuList(data) {
  return request({
    url: `${ApiModulesRoutes.USER}/menu/updateMenu`,
    method: 'POST',
    data,
  })
}
